package io.filecopy;

import java.io.File;
import java.io.IOException;

public class CopyTest {

  public static void main(String[] args) throws InterruptedException,
      IOException {
    File srcDir = new File("E:/data/m500926/Temp/copy/src");
    File dstDir = new File("E:/data/m500926/Temp/copy/dst");
    // File srcDir = new File("E:/data/m500926/workspace/RSA8_LAS_HEAD");
    // File dstDir = new File("E:/data/m500926/workspace/RSA8_LAS_HEAD_BACKUP");

    JobDescription description = new JobDescriptionImpl(srcDir, dstDir, null,
        DirectoryMode.ALL_FILES_AND_SUBDIRECTORIES,
        LastModifyTimeMode.OVERWRITE_SOURCE_TIME,
        ReplaceMode.REPLACE_DIFFERENT,
        SynchronizeMode.REMOVE_NOT_EXISTING_SOURCE_ENTRIES);

    JobExecutor executor = new JobExecutor(description);
    executor.addJobPreparationListener(new InfoJobPreparationListener());
    executor.start();
    executor.join();
    ProgressLogger progress = executor.getProgressLogger();
    synchronized (System.out) {
      progress.printInfo(executor.getJob());
    }
  }

  static class InfoJobPreparationListener implements JobPreparationListener {

    @Override
    public void jobInfoChanged(PreparedJob job) {

    }

    @Override
    public void preparationCompleted(PreparedJob job) {
      synchronized (System.out) {
        ((PreparedJobImpl) job).printInfo();
        System.out.println("---");
      }
    }
  }
}